package com.ruoyi.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysBusiness;
import com.ruoyi.project.system.service.ISysBusinessService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 创业内容Controller
 *
 * @author theme
 * @date 2020-08-27
 */
@Api(description = "创业内容Controller" )
@RestController
@RequestMapping("/system/business" )
public class SysBusinessController extends BaseController {
    @Autowired
    private ISysBusinessService sysBusinessService;

/**
 * 查询创业内容列表
 */
@ApiOperation("查询创业内容列表" )
@PreAuthorize("@ss.hasPermi('system:business:list')" )
@GetMapping("/list" )
        public TableDataInfo list(SysBusiness sysBusiness) {
        startPage();
        List<SysBusiness> list = sysBusinessService.selectSysBusinessList(sysBusiness);
        return getDataTable(list);
    }
    
    /**
     * 获取创业内容详细信息
     */
    @ApiOperation("获取创业内容详细信息" )
    @PreAuthorize("@ss.hasPermi('system:business:query')" )
    @GetMapping(value = "/{businessId}" )
    public AjaxResult getInfo(@PathVariable("businessId" ) Long businessId) {
        return AjaxResult.success(sysBusinessService.selectSysBusinessById(businessId));
    }

    /**
     * 新增创业内容
     */
    @ApiOperation("新增创业内容" )
    @PreAuthorize("@ss.hasPermi('system:business:add')" )
    @Log(title = "创业内容" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysBusiness sysBusiness) {
        return toAjax(sysBusinessService.insertSysBusiness(sysBusiness));
    }

    /**
     * 修改创业内容
     */
    @ApiOperation("修改创业内容" )
    @PreAuthorize("@ss.hasPermi('system:business:edit')" )
    @Log(title = "创业内容" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysBusiness sysBusiness) {
        return toAjax(sysBusinessService.updateSysBusiness(sysBusiness));
    }

    /**
     * 删除创业内容
     */
    @ApiOperation("删除创业内容" )
    @PreAuthorize("@ss.hasPermi('system:business:remove')" )
    @Log(title = "创业内容" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{businessIds}" )
    public AjaxResult remove(@PathVariable Long[] businessIds) {
        return toAjax(sysBusinessService.deleteSysBusinessByIds(businessIds));
    }
}
